package cn.mymall.web.controller.houtai.member;

import cn.mymall.entity.Member;
import cn.mymall.service.IMemberService;
import cn.mymall.support.ResultCode;
import cn.mymall.vo.member.MemberReqVo;
import cn.mymall.web.controller.houtai.BaseHoutaiController;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/member")
public class MemberController extends BaseHoutaiController {
    @Autowired
    private IMemberService memberService;
    @RequestMapping("/list")
    public ResultCode memberList(MemberReqVo reqVo) {
        return ResultCode.getSuccessReturn(memberService.queryPage(reqVo));
    }

    @RequestMapping("/setStatus")
    public ResultCode setStatus(Integer id, String status) {
        if(StringUtils.isBlank(status)){
            return ResultCode.getFailure("status is null");
        }
        Member member = memberService.getById(id);
        member.setStatus(status);
        memberService.updateById(member);
        return ResultCode.SUCCESS;
    }
}
